<template>
	<view class="selectLabel">
		<view class="item-content">
			<view v-for="item in examList" :key="item.id" @click="handleExamType(item.id)" :class = "currentExamIndex == item.id ? 'active':''">{{item.name}}</view>
		</view>
		<view class="item-content">
			<view v-for="item in topicList" :key="item.id" @click="handleTopicType(item.id)" :class = "currentTopciIndex == item.id ? 'active':''">{{item.name}}</view>
		</view>
	</view>
</template>

<script> 
	export default {
		data(){
			return {
				currentExamIndex: 0,
				currentTopciIndex: 0
			}
		},
		props:{
			examList: {
				type: Array,
				default: []
			},
			topicList: {
				type: Array,
				default: []
			}
		},
		methods: {
			handleExamType(id){
				// console.log(id);
				this.currentExamIndex = id;
				this.$emit("labelType",{
					type: 1,
					index : this.currentExamIndex
				});
			},
			handleTopicType(id){
				this.currentTopciIndex = id;
				this.$emit("labelType",{
					type: 2,
					index : this.currentTopciIndex
				});
			}
		}
		
	}
</script>

<style lang="scss">
.selectLabel{
	width: 100%;
	display: flex;
	flex-direction: column;
	padding: 10rpx 0 0 0 ;
	.item-content{
		display: flex;
		flex-wrap: wrap;
		margin: 5rpx 0;
		view{
			display: flex;
			justify-content: center;
			align-items: center;
			width: 18%;
			height: 48rpx;
			background: #fff;
			border-radius: 20rpx;
			font-size: 28rpx;
			font-weight: 300;
			color:#212121;
			// margin-right: 20rpx;
			margin: 20rpx 20rpx 0 0 ;
			padding: 6rpx 10rpx;
		}
		.active{
			background: #66BB6A;
			color: #fff;
		}
	}
}
</style>
